//
//  PerHeaderView.m
//  Ecrm
//
//  Created by ZHC on 16/3/15.
//  Copyright © 2016年 ZHC. All rights reserved.
//

#import "PerHeaderView.h"

@implementation PerHeaderView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = HCRandomColor;
    
        
    }
    
    return self;
}

/**
 *  设置数据模型
 *
 *  @param model <#model description#>
 */
-(void)setModel:(PerHeaderModel *)model{
    _model = model;
    
    self.name.text = model.truename;
    
    self.position.text = model.zhiwei;
    
    [self layoutView];
    
    
}

/**
 *  通过模型布局
 */
-(void)layoutView{
    
//    self.pic.frame = CGRectMake(0, 0, screenWidth, 150);
//    self.pic.backgroundColor = HCRandomColor;
//    [self addSubview:self.pic];
    
    HCLog(@"-----%f",screenWidth*0.65);
    
    self.headbg.frame = CGRectMake(screenWidth*0.05, screenWidth*0.65-(screenWidth*(90/screenWidth)/2+10)-screenWidth*(90/screenWidth)/2, screenWidth*(90/screenWidth), screenWidth*(90/screenWidth));
    self.headbg.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.3];
    [self.headbg.layer setCornerRadius:screenWidth*(90/screenWidth)/2];
    [self addSubview:self.headbg];
    
    self.name.frame = CGRectMake(screenWidth*0.05+screenWidth*(90/screenWidth)+15, screenWidth*0.65-(screenWidth*(90/screenWidth)/2+10)-21, 200, 16);
    self.name.font = [UIFont boldSystemFontOfSize:16.0f];
    self.name.textColor = [UIColor whiteColor];
    [self addSubview:self.name];
    
    self.grayView.frame = CGRectMake(0, screenWidth*0.65-(screenWidth*(90/screenWidth)/2+10), screenWidth, screenWidth*(90/screenWidth)/2+10);
    self.grayView.backgroundColor = HCColor(240, 240, 240);
    [self addSubview:self.grayView];
    
    self.head.frame = CGRectMake(screenWidth*0.05+6, screenWidth*0.65-(screenWidth*(90/screenWidth)/2+10)-(screenWidth*(90/screenWidth)-12)/2, screenWidth*(90/screenWidth)-12, screenWidth*(90/screenWidth)-12);
    self.head.backgroundColor = HCRandomColor;
    self.head.clipsToBounds = YES;
    [self.head.layer setCornerRadius:(screenWidth*(90/screenWidth)-12)/2];
    [self addSubview:self.head];
    
    self.position.frame = CGRectMake(screenWidth*0.05+screenWidth*(90/screenWidth)+15, screenWidth*0.65-(screenWidth*(90/screenWidth)/2+10)+5, 200, 14);
    self.position.font = [UIFont systemFontOfSize:14.0f];
    self.position.textColor = HCColor(110, 110, 110);
    [self addSubview:self.position];
    
}

- (UIImageView *)pic
{
    if(_pic == nil)
    {
        _pic = [[UIImageView alloc] init];
    }
    return _pic;
}

- (UIImageView *)headbg
{
    if(_headbg == nil)
    {
        _headbg = [[UIImageView alloc] init];
    }
    return _headbg;
}

- (UIImageView *)head
{
    if(_head == nil)
    {
        _head = [[UIImageView alloc] init];
    }
    return _head;
}

- (UIView *)grayView
{
    if(_grayView == nil)
    {
        _grayView = [[UIView alloc] init];
    }
    return _grayView;
}

- (UILabel *)name
{
    if(_name == nil)
    {
        _name = [[UILabel alloc] init];
    }
    return _name;
}

- (UILabel *)position
{
    if(_position == nil)
    {
        _position = [[UILabel alloc] init];
    }
    return _position;
}

@end
